/**
 * Copyright (c) 2018-2028, Chill Zhuang 庄骞 (smallchill@163.com).
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springblade.modules.evaluate.service.impl;

import org.springblade.core.tool.utils.Func;
import org.springblade.modules.evaluate.entity.Evaluate;
import org.springblade.modules.evaluate.vo.EvaluateVO;
import org.springblade.modules.evaluate.mapper.EvaluateMapper;
import org.springblade.modules.evaluate.service.IEvaluateService;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

import java.util.ArrayList;
import java.util.List;

/**
 * 评价表 服务实现类
 *
 * @author Blade
 * @since 2021-03-10
 */
@Service
public class EvaluateServiceImpl extends BaseServiceImpl<EvaluateMapper, Evaluate> implements IEvaluateService {

	@Override
	public IPage<EvaluateVO> selectEvaluatePage(IPage<EvaluateVO> page, EvaluateVO evaluate) {
		return page.setRecords(baseMapper.selectEvaluatePage(page, evaluate));
	}

	@Override
	public List<EvaluateVO> evaluateList(String commodityId) {
		List<EvaluateVO> evaluateVOS = baseMapper.evaluateList(commodityId);
		for (EvaluateVO evaluateVO : evaluateVOS) {
			List<String> strings = Func.toStrList(evaluateVO.getImg());
			List<String> imgList = new ArrayList<>();
			for (String string : strings) {
				imgList.add("http://localhost:7777"+string);
			}
			evaluateVO.setImgList(imgList);
		}
		return evaluateVOS;
	}

}
